Topic 8. Analysis modeling Introduction Visualizing, specifying, building and documenting a software intensive application requires that the application be viewed from various perspectives by different users (end users, analysts, developers, integrators, testers, project managers, among others). The design of the applications is of utmost importance so that during the implementation phase the team in charge of developing the application knows at a functional and technical level which are its characteristics, the expected functionality and, above all, the structure with which the software will be built. One of the oldest questions in software methods is: How can a large system be fragmented into smaller ones? We ask this because, as systems become larger, it gets harder to understand them and their changes. Hence the importance of structured methods ; these made use of functional decomposition, in which the system as a whole was correlated as a function and divided into sub-functions, which at the same time were divided into other sub-functions, and so on and so forth. Functions were like use cases in an object-oriented system, where functions represented something that the system did as a whole. Those were the days when process and data were separate. So, in addition to a functional decomposition, there also was a data structure. The latter occupied the second place, although certain information engineering techniques grouped data records into thematic areas and produced matrices that showed the interrelation between functions and data records. 13/10/25, 2:41 p.m. Topic https://utm-cdn-labcontenidos-htfaarehf2gcfycs.a01.azurefd.net/contenido/profesional/lsti1813/contenido/08tema.html 1 / 16
It is from this point of view that we can appreciate the great change that the objects have meant. The separation between process and data, and the functional decomposition is gone, but the old question remains. One of the most difficult issues to understand in an object-oriented program is the general control flow. A good design has lots and lots of little methods in different classes, and sometimes it is very complicated to determine the overall behavior sequence. You may end up reading the code, trying to find where the program is. This is how it happens; especially for all those who start working with objects. The sequence diagrams we will look at in this topic help you to see the sequence. Explanation 8.1 Interaction Models According to rcasalla (2021), Software Design in interaction models is the set of activities in which a product's requirements are transformed through a series of decisions, into abstractions that will facilitate the developer in programming and testing the software. These abstractions are the design  and must include, at a minimum, the following: The main parts of the product. How the parts interact with each other. How the parts should be assembled to produce the final product. These abstractions, as noted by rcasalla (2021), should be able to be, on the one hand, evaluated as follows: 1. Against the requirements to see if they will be able to be satisfied in the code. 2. Against criteria like coupling, cohesion, separation of responsibilities. You should always be able to justify a design decision. On the other hand, abstractions should also include the following criteria: 1. Be expressed in unambiguous terms. 13/10/25, 2:41 p.m. Topic https://utm-cdn-labcontenidos-htfaarehf2gcfycs.a01.azurefd.net/contenido/profesional/lsti1813/contenido/08tema.html 2 / 16
2. Be a clear guide for the product's implementation, meaning, it must produce an accurate and complete specification of how the product will be built. The Challenges of Software Design The vast majority of software development projects are projects of great uncertainty in terms of many factors: requirements, users, technology, development team, etc. These projects are projects of collective construction of knowledge where uncertainty gradually decreases. These gradual processes (iterative, cyclic) are more complex than those where the stages and the results of each are clear. Software projects would be easier if you could have complete requirements specification at the analysis stage and then complete design at the design stage and then programming and testing without having to go back and question requirements or designs. However, this is very rarely possible. It is usual that the requirements are changing and that these changes affect the design or that once in programming we discover that the design was not adequate or that the particular technology does not support some design idea we had (rcasalla, 2021). Some of the challenges of Software Design can be summarized as follows: 1. The Requirements are defined or incomplete or changing: This will mean that the designs must be in turn changing, adapting, maintaining. 2. Designs cannot always be separated from the technologies on which the application will be implemented. 3. The evaluation of the design, the justification. 4. The expression of design (abstractions). 5. The evolution of design. 8.2 Design diagrams Class diagrams are used to represent structural aspects of an object-oriented system. These diagrams are one of the 13 types of diagrams belonging to the UML 2.0 standard. Class diagrams show the building blocks of a system and the 13/10/25, 2:41 p.m. Topic https://utm-cdn-labcontenidos-htfaarehf2gcfycs.a01.azurefd.net/contenido/profesional/lsti1813/contenido/08tema.html 3 / 16
relationships between these blocks. This map of blocks and relationships is known as the static view of the object-oriented system. (rcasalla, 2021). The following figure shows an example of a class diagram: Figure 1 This example models the main elements of a university through a class diagram. The example illustrates the basic element types: classes and associations. (rcasalla, 2021). Click on each item for detailed information Classes According to rcasalla (2021), every class has an explicit name that, by convention, should: 1. Start with a capital letter. 2. If it is a name composed of several words, use camelCase, that is, each new word starts with a capital letter. V.gr .,  UniversityStudent Attributes 13/10/25, 2:41 p.m. Topic https://utm-cdn-labcontenidos-htfaarehf2gcfycs.a01.azurefd.net/contenido/profesional/lsti1813/contenido/08tema.html 4 / 16
The other important element of class diagrams is association. An association, by definition, relates two classes in the diagram and they are represented using one line. Each association can have a name. If present, the name goes in the middle of the line that represents it. The name of the association, by convention: 1. Start with a lowercase letter. 2. If the name is composed of several words, Camel Case is used. 3. It is significant of what it represents. In the following figure there are two associations between the Course  class and the Student class: One to associate the students with a course are they are seeing over ( isSeenBy ) and Each class can have one or more attributes that appear in the second compartment of the rectangle. The Student class in the example has attributes such as age , name , gender , among others. Each attribute is expressed with a name, a visibility and a data type. By convention, the attribute name begins with a lowercase letter, for example,  age. If the name is compound camelCase is used, for example,  dateOfBirth (rcasalla, 2021). Method In the third compartment the methods of the class are proposed. Each method also has a name, a visibility, a list of parameters and a return data type.  By convention, method names start with a lowercase letter. If the method name is compound Camel Case is used, in general,  calculateSemesterGPA . Like attributes, methods have a visibility that can be public, private or protected. The parameter list can have zero or several parameters of a certain type (rcassalla, 2021). Association 13/10/25, 2:41 p.m. Topic https://utm-cdn-labcontenidos-htfaarehf2gcfycs.a01.azurefd.net/contenido/profesional/lsti1813/contenido/08tema.html 5 / 16
another to represent the students attending as visitors ( visitedBy ). (rcasalla, 2021). Figure 2. Example of associations (rcasalla, 2021). The properties that they can have of the elements of a class diagram can be the following: Click on each item for detailed information Visibility defines whether the properties of classes (that is, attributes and methods) can be seen or used by other classes. The visibility levels are public, private or protected, which are represented by the +, -, # icons, respectively. In the example,  age  is a private attribute. A private property can be seen and used only by the class that contains it. A public property can be viewed and used by the class that contains it and by any other class. A protected property can be viewed and used only by the class that contains it and by its subclasses. (rcasalla, 2021). Visibility Type The data type of an attribute can be primitive or user- defined. The primitive types of standard UML are (rcasalla, 2021): Boolean Integer UnlimitedNatural String 13/10/25, 2:41 p.m. Topic https://utm-cdn-labcontenidos-htfaarehf2gcfycs.a01.azurefd.net/contenido/profesional/lsti1813/contenido/08tema.html 6 / 16
Real Cardinality In the example of Figure 1 there are several associations. There is one between  Course  and  Classroom : which means that  each  of the objects of the  Course  class is associated with  one  (and only one) object of the Classroom class. To indicate that only one course and only one classroom are involved in the association, the number 1 is written at the end next to the corresponding class (not writing any number means that the cardinality is 1). In Figure 2, in the associations isViewedBy and visitedBy , the cardinality of the Student and Course classes is multiple (represented by the * symbol ). It means that given an object of the Course class, it has an association with a set of objects of Student class. In the other sense it means that: a student can be associated with several objects in the Course class. (rcasalla, 2021). The cardinality of the role can be an integer or an expression. For example (rcasalla, 2021): 1 1..5 minimum 1 maximum 5 0..1 zero or one * zero or many 1..* one or many Roles In the example above the set of target students of the association isViewedBy is called students. This name is called the role of the Student class in the association (rcasalla, 2021). 13/10/25, 2:41 p.m. Topic https://utm-cdn-labcontenidos-htfaarehf2gcfycs.a01.azurefd.net/contenido/profesional/lsti1813/contenido/08tema.html 7 / 16
Types of Associations Figure 3 shows the different types of associations that can exist between two classes in a UML class diagram: (rcasalla, 2021). Figure 3: Types of associations. Click on each item for detailed information Navigability Navigability is indicated by the tip of the arrow. In the example of Figure 1, the arrowhead indicates that in an association between an object of the Course class and an object of the Classroom class, the Course object has access to the classroom object (the direction in which the arrow points are taken). From this we can deduce that Classroom does not have access to Course since the association does not point in that direction. The absence of an arrowhead at both ends of the relationship usually means, that generally, there is navigability in both directions (rcasalla, 2021). Aggregation or shared association 13/10/25, 2:41 p.m. Topic https://utm-cdn-labcontenidos-htfaarehf2gcfycs.a01.azurefd.net/contenido/profesional/lsti1813/contenido/08tema.html 8 / 16
Its corresponding notation is an empty rhombus. In Figure 2, the association between Course and Students is of this type. Suppose we have the objects c1 and c2 of the Course  class and some objects of the Student  class which we will call e1, e2, e3 and e4 We will now represent two collections of students. Students1 will be an associated collection, through  isSeenBy , with the c1 course and containing the e1, e2 and e3 objects. Students2 will be a collection associated with the course c2 that contains the objects e3 and e4 (rcasalla, 2021). Figure 4. Example aggregation association. Note that the e3 object is shared by the students1 and students2 collections of the C1 and c2 objects. Composite or strong aggregation association. Its corresponding notation is a filled rhombus. In Figure 2, the association between University and Program is of this type. Which means that if we have two universities u1 and u2; the u1 university programs cannot be u2 university programs. Figure 5 illustrates the case (rcassalla, 2021): 13/10/25, 2:41 p.m. Topic https://utm-cdn-labcontenidos-htfaarehf2gcfycs.a01.azurefd.net/contenido/profesional/lsti1813/contenido/08tema.html 9 / 16
8.3 Other diagrams Sequence Diagrams Among the UML 2.0 diagrams to represent behavior, there are diagrams that emphasize aspects of interaction between objects. These include communication, interaction, sequence and time diagrams. Sequence diagrams allow modeling the sequence of interactions between different objects to achieve some tasks, whether it is a scenario of a use case, the logic of a method or the logic of a service (rcasalla, 2021). Basic elements of the diagram Objects and their lifeline Based on rcasalla (2021), objects, not classes, are represented. An object is represented by a rectangular box and a dotted line coming out of the box downwards. The class of which the object is an instance must be indicated and if the same object needs to be mentioned Figure 5. "Composite" or strong aggregation association example. We say that strong aggregation associations have two properties: 1. Exclusivity (as in the previous example) and 2. Existentiality, meaning that if the source object is destroyed (in the u1 example), the destination objects are destroyed (in the p1, p2 and p3 example) (rcasalla, 2021). 13/10/25, 2:41 p.m. Topic https://utm-cdn-labcontenidos-htfaarehf2gcfycs.a01.azurefd.net/contenido/profesional/lsti1813/contenido/08tema.html 10 / 16
elsewhere in the diagram, it is given a name. In the following figure, the object is called u1 and is an instance of the class University: The dotted line coming out of the box is called the object's lifeline. This line is used to define an order in the actions performed by the object (the order of actions goes from top to bottom). When an object appears in a sequence diagram, it means that it is active in execution, meaning, other objects can communicate with it (rcasalla, 2021). Interaction between objects The interaction between objects is carried out through messages that are sent to each other. In the figure, the obj3 object of the Class2class sends a message called "Message Example” to the object obj1 instance of the class Class1 (rcasalla, 2021). 13/10/25, 2:41 p.m. Topic https://utm-cdn-labcontenidos-htfaarehf2gcfycs.a01.azurefd.net/contenido/profesional/lsti1813/contenido/08tema.html 11 / 16
Messages can be of different types: synchronous or asynchronous, lost, found, called or signaled. For now, we are going to focus on synchronous methods that correspond to method calls. The difference in the diagram is in the type of arrow: Fragment Combined: alternative paths To represent alternatives or conditional executions in the sequence diagrams we must resort to the combined fragments. A combined fragment is a logical grouping, represented by a rectangle containing the conditional structure that affects the flow of messages (rcasalla, 2021). 13/10/25, 2:41 p.m. Topic https://utm-cdn-labcontenidos-htfaarehf2gcfycs.a01.azurefd.net/contenido/profesional/lsti1813/contenido/08tema.html 12 / 16
Combined Fragments: cycles Suppose we are now interested in modeling the behavior of the use case: "Calculate the number of students whose gender is female and are enrolled in a course, given its code, of a program given the name of the program.” There are several questions that we need to ask ourselves (rcasalla, 2021). 1. Who is responsible for knowing a student's gender? 2. Who is responsible for knowing how many students of the female gender are in a course? 3. Who is responsible for finding the course that corresponds to a given code? 4. Who is responsible for finding the program that corresponds to a given name? 5. Who is responsible for receiving from the external stakeholder the information on the program name and course code for which you want to know how many women there are? When answering the questions using the expert pattern, we got the updated class diagram: Answers to the questions: 13/10/25, 2:41 p.m. Topic https://utm-cdn-labcontenidos-htfaarehf2gcfycs.a01.azurefd.net/contenido/profesional/lsti1813/contenido/08tema.html 13 / 16
1. "Who is responsible for knowing a student's gender?": the "Student" class who has the information. 2. "Who is responsible for knowing how many students with a female gender there are in a course? The "Course" class that has access to the collection of students enrolled in it. 3. Who is responsible for finding the course that corresponds to a given code? With this question we decided that the courses belong to University and not to the programs, for that reason a new relationship was created even though this increases the coupling. A course can be taught in more than one program. 4. Who is responsible for finding the program that corresponds to a given name? The "University" is the owner of the programs. 5. Who is responsible for receiving from the external actor the information of the name of the program and the course code about which you want to know how many women there are?... "University". The sequence diagram with the combined fragment representing the cycle is: 13/10/25, 2:41 p.m. Topic https://utm-cdn-labcontenidos-htfaarehf2gcfycs.a01.azurefd.net/contenido/profesional/lsti1813/contenido/08tema.html 14 / 16
We iterate over the collection of students and for each one we ask the gender. If it is value is F, then it is counted in the woman variable. Instruction student=*next() it allows to advance in the cycle (rcasalla, 2021). Conclusion In summary, it is concluded that different developers have different preferences when it comes to selecting the form of interaction diagram they will use. Usually, some of them prefer the sequence diagram because they like the emphasis it places on sequence; it is easy to appreciate the order in which things happen. Others, on the other hand, prefer the collaboration diagram, because they can use the layout to indicate how the objects are statically connected. One of the main features of both types of interaction diagrams is their simplicity. You can easily see the messages by just looking at the diagram. To learn more about creating a sequence diagram , watch the following video: 13/10/25, 2:41 p.m. Topic https://utm-cdn-labcontenidos-htfaarehf2gcfycs.a01.azurefd.net/contenido/profesional/lsti1813/contenido/08tema.html 15 / 16
Master2Teach. (2020, April 15). Sequence Diagram - Step by Step Guide with Example [Video file] Retrieved from https://www.youtube.com/watch? v=_Mzi1rYtI5U The following link do not belong to Tecmilenio University, when accessing to them, you must accept their terms and conditions. Checkpoint Make sure you: Understand the different types of application modeling diagrams. Identify the different types of design diagrams. Design different types of diagrams in a CASE tool. References rcasalla. (2021). UML diagramas de clases. Retrieved from https://rcasalla.gitbooks.io/libro-desarrollo-de- software/content/libro/temas/t_uml/uml_diagramasclase.html 13/10/25, 2:41 p.m. Topic https://utm-cdn-labcontenidos-htfaarehf2gcfycs.a01.azurefd.net/contenido/profesional/lsti1813/contenido/08tema.html 16 / 16